<?php

namespace App\Http\Controllers\Api\V2;

use Illuminate\Http\Request;
use App\Http\Requests\ApiV2\EquipmentRequest;
use App\Services\Warehouse\Interfaces\EquipmentServiceInterface;
use Illuminate\Support\Facades\DB;
use App\Services\Warehouse\Services\EquipmentService;

class EquipmentController extends BaseController
{
    /**
     * @var Equipment
     */
    protected $equipmentService;

    public function __construct(EquipmentServiceInterface $equipmentService)
    {
        $this->equipmentService = $equipmentService;
    }


    public function index(Request $request)
    {
        $equipment = $this->equipmentService->index($request->all());
        return $this->data($equipment);
    }

    public function store(EquipmentRequest $request)
    {
        $this->equipmentService->set($request->filldata());
        return $this->success();
    }

    public function edit($id)
    {
        $equipment = $this->equipmentService->get($id);
        return $this->data($equipment);
    }

    public function update(EquipmentRequest $request, $id)
    {
        $this->equipmentService->set($request->filldata(), $id);
        return $this->success();
    }

    public function destroy($id)
    {
        $this->equipmentService->destroy($id);
        return $this->success();
    }
}
